<?php 
session_start();
include("../db_connect.php");
include("../shop/functions.php");
include("../class/objName.php");

	
	
	if(!isset($_SESSION['id'])|| !isset($_SESSION['fname']) ||!isset($_SESSION['password']) ){
		
		$item_display = "You Must login 1st";
		header("location: ../index.php");
		exit();
	}
	else{
		if(!isset($_SESSION['cart'])){
			$item_display = "YOU DONT HAVE ANY ITEM IN YOUR CART 12";
			die();
		}else{
			$max=count($_SESSION['cart']);
				$item = "";//hidden data of the field
				$item_Name = "";
				$item_Price = "";
				$item_total_amount ="";
				$item_display = "";//layout of the item
				if($max > 0){
					for($i=0;$i<$max;$i++){
						$pid=$_SESSION['cart'][$i]['productid'];
						$qty= $_SESSION['cart'][$i]['qty'];
						$item_Name = get_product_name($pid);
						$item_Price = get_price($pid);
						$item_total_amount = $qty * $item_Price;
						$q = $i+1;
						 
						$item .= '<input type="hidden" name="item_name_'.$q.'" value="'.$item_Name.'"/>';
						$item .= '<input type="hidden" name="item_number_'.$q.'" value="'.$pid.'"/>';
						$item .= '<input type="hidden" name="quantity_'.$q.'" value="'.$qty.'"/>';
						$item .= '<input type="hidden" name="amount_'.$q.'" value="'.$item_Price.'"/>';
						$item .= '<input type="hidden" name="option_name_'.$q.'" value="Fullpaid"/>'; 
						$result = mysql_query("SELECT * FROM tblswaping where id='".$pid."'");
						/**/
						while($row = mysql_fetch_array($result)){ 
								$obj = new objName();
								$img = $obj->displayimg($row['filename'],true);
								$item_display .= "	<tr style=' border: 1px solid white;'>";
								$item_display .= "<td valign='top' width='100px'>
									<img id='' style='width:200px; height:90px;' src='../images/vehicles/$img'>
									<div>Posted by:<a href='#' style='color:red;' > ".$row['fname'] ." ".$row['lname'] . "</a>";                                            
								$item_display .= "<p>Name:".$row['name']."</br> Time posted:".$row['timepost']."</br><a href='../preview.php?from=admin.&pageid=".$row['id']."' style='color:red'>Preview</a></p>";
								$item_display .= "</div></td>";
								$item_display .="<td valign='top' width='120px'><div width='120'>";
									
									if($row['categories']== "Auto"){
										$item_display .="Price: ".$row['price']."</br>";
										$item_display .="Brand: ".$row['brand']."</br>";
										$item_display .="Model: ".$row['model']."</br>";
										$item_display .="Condition: ".$row['conditions']."</br>";
										$item_display .="Categories: ".$row['categories']."</br>";
										$item_display .="Type: ".$row['types']."</br>";
										$item_display .="Trans: ".$row['transmission']."</br>";
										$item_display .="Fuel: ".$row['fuel']."</br>";
										
									}
									else{
										$item_display .="Price: ".$row['price']."</br>";
										$item_display .="Condition: ".$row['conditions']."</br>";
										$item_display .="Categories: ".$row['categories']."</br>";
										$item_display .="Parts: ".$row['cparts']."</br>";
										$item_display .="Quanity: ".$qty."</br>";
									}
									
										
								$item_display .= "</div></td>";
								
								$item_display .="<td valign='top'><p align='justify'>" .$row['description']."</p></td>";
							$item_display .="</tr>";
					
						}
						
						
						
						
						
						
						
						/**/
					}
				}
				else{
					$item_display = "YOU DONT HAVE ANY ITEM IN YOUR CART 1";
				}
		}
	}	
	
	
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Basciautosales store the place where you can buy trade set build your own dream cars at its your ways" />
<meta name="description" content="Basciautosales store the place where you can buy trade set build your own dream cars at its your ways" />

<?php include("include/jquery.php");?>
<style>
    tr { 
        display: table;            /* this makes borders/margins work */
        border: 1px solid black;
       	width:100%;
		margin: 2px 0px 0px 0px;
	}
</style>
</head>

<body> <div id=" msgbox"></div>
<div id="toolbar">
<div id="templatemo_wrapper">
	<div id="templatemo_header">
    <!--header-->
		<?php include("include/header.php");?>
	<!--header-->
    </div> <!-- END of templatemo_menu -->
    
    <div id="templatemo_main">
   		
		<!--sidebar-->
		<div id="sidebar" class="float_l">
			
        	<!--endtop-->
				
		</div><!--siderbar-->
		
		
		
        <div id="content" class="faq float_r" style="background-color:black">
			<h2 style="color:white">Check Out Page</h2>
				<form  style="float:right;" action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="blank_" method="post">
				<input type="hidden" name="cmd" value="_cart"/>
				<input type="hidden" name="upload" value="1"/>
				<input type="hidden" name="business" value="basci_1358759599_biz@yahoo.com.ph"/> 
				<input type="hidden" name="currency_code" value="BGP"/>
				<input type="hidden" name="custom" value="<?php 
				
				if(isset($_SESSION['id'])){
				echo $_SESSION['id'];
				}
				?>"/>
				
				<?php echo $item;?>
				
				<input type="hidden" name="return" value="http://basciautosales.zz.mu/shop.php">
				<input type="hidden" name="cancel_return" value="http://basciautosales.zz.mu">
				<input type="hidden" name="notify_url" value="http://basciautosales.zz.mu/paypal/index.php">
				<input class="button" type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
				</form>
				
				<table border='0' width='100%'>
					<?php echo $item_display;?>
				</table>
			
				<form style="float:right;" action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="blank_" method="post">
				<input type="hidden" name="cmd" value="_cart"/>
				<input type="hidden" name="upload" value="1"/>
				<input type="hidden" name="business" value="tinda_1358228399_biz@yahoo.com"/>
				<input type="hidden" name="currency_code" value="BGP"/>
				<input type="hidden" name="custom" value="<?php 
				
				if(isset($_SESSION['id'])){
				echo $_SESSION['id'];
				}
				?>?>"/>
				
				<?php echo $item;?>
				
				<input type="hidden" name="return" value="http://basciautosales.zz.mu/shop.php">
				<input type="hidden" name="cancel_return" value="http://basciautosales.zz.mu">
				<input type="hidden" name="notify_url" value="http://basciautosales.zz.mu/paypal/index.php">
				<input class="button" type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"/>
				</form>
				
			
			
		<!--end of place order-->
	   </div> 
        <div class="cleaner"></div>
    </div> <!-- END of templatemo_main -->
    
     <!--footer-->
	<?php include("include/footer.php");?>
    
</div> <!-- END of templatemo_wrapper -->
</div>
</body>
</html>